package com.example.petplatform.config;
//import com.example.childmall.Utils.JwtInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfig implements WebMvcConfigurer {

//    @Bean
//    public JwtInterceptor jwtInterceptor() {
//        return new JwtInterceptor();
//    }

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        // 修改静态资源的路径映射
        registry.addResourceHandler("/image/**")  // 设置访问路径前缀
                .addResourceLocations("classpath:/static/image/");  // 设置资源所在的文件夹
    }

    //添加自定义拦截器JwtInterceptor
    //添加拦截器，拦截所有请求，但是排除登录和注册接口
//    @Override
//    public void addInterceptors(InterceptorRegistry registry) {
//        registry.addInterceptor(jwtInterceptor())
//                .addPathPatterns("/**")  // 拦截所有请求
//                .excludePathPatterns(
//                    "/login/adminLogin",
//                    "/login/userLogin",
//                    "/login/register",
//                    "/Userfile/**",
//                    "/file/**",
//                    "/image/**",  // Changed from /image/
//                    "/static/**", // Changed from /static/image/
//                    "/resources/**",
//                    "/error"      // Added error path
//                );  // 排除登录和注册接口
//    }
}
